﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using System.Text.RegularExpressions;
using FredCK.FCKeditorV2;
using Lswweb.Domain;
using Lswweb.Model;

namespace Lswweb.Controls
{
    public class SendEmail : SkinnedWebControl
    {
        private TextBox tbxTitle;
        private TextBox tbxToEmails;
        private IButtonControl btnConfirm;
        private FCKeditor editor;

        protected override void InitializeSkin(System.Web.UI.Control skin)
        {
            tbxTitle = skin.FindControl<TextBox>("tbxTitle");
            tbxToEmails = skin.FindControl<TextBox>("tbxToEmails");
            editor = skin.FindControl<FCKeditor>("editor");
            btnConfirm = (IButtonControl)skin.FindControl("btnConfirm");

            btnConfirm.Click += new EventHandler(btnConfirm_Click);
        }

        void btnConfirm_Click(object sender, EventArgs e)
        {
            Email.SendMail(this.Settings.SmtpEmail, tbxTitle.GetValue<string>(), editor.Value, tbxToEmails.GetValue<string>().Split(','));
        }

        protected override string DefaultSkinFilename
        {
            get { return ""; }
        }
    }
}
